<script type="text/javascript">
	
function verif(txt,min) {
	var val = txt.value;
	var lignes = val.split("\n");
	var nb = 0;
	for(var i=0;i<lignes.length;i++) {
	nb += lignes[i].length==0?1:Math.ceil(lignes[i].length / txt.cols);
	}
	if(nb>=min) txt.rows = nb;
	else txt.rows = min;
}

function findLableForControl(field)
{
	var idVal = field.id;
	labels = document.getElementsByTagName('label');
	for(var i = 0; i < labels.length; i++)
	{
		if (labels[i].htmlFor == idVal)
			return labels[i];
	}
}

function highlight(field, error)
{
	var label = findLableForControl(field);
	if(error)
    {
		field.style.borderColor = "#FF0000";
		label.style.color = "#FF0000";
	}
	else
	{
		field.style.borderColor = "";
		label.style.color = "";
	}
}

function checkFieldNotEmpty(field)
{
	if(field.value.length==0)
	{
		highlight(field, true);
	}
	else
	{
		highlight(field, false);
	}
}

function checkIdentical(field2, checkNotEmpty)
{
	labelField2 = field2.getAttribute('name');
	labelField1 = labelField2.substring(0, labelField2.length-1);
	field1 = document.getElementsByName(labelField1)[0];
	same = (field1.value == field2.value);
	empty = (field1.value.length == 0 || field2.value.length == 0);
	if(checkNotEmpty)
	{
		if(same && !empty)
		{
			highlight(field1, false);
			highlight(field2, false);
		}
		else
		{
			highlight(field1, true);
			highlight(field2, true);
		}
	}
	else
	{
		if(same)
		{
			highlight(field1, false);
			highlight(field2, false);
		}
		else
		{
			highlight(field1, true);
			highlight(field2, true);
		}
	}

}

function checkMail(mail)
{
	
}

function checkMobile(mobile)
{
	
}

function redirect(contestid, view, dateround)
{
	var url = "contest.php?contestid=".contestid."&view=events&seeEvents=".dateround;
	window.location=url;
}
</script>



